package cz.czu.pef.DataModelling.beans.common;

import java.io.Serializable;
import java.util.Locale;
import java.util.logging.Logger;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

@ManagedBean
@SessionScoped
public class LocaleBean implements Serializable
{
	private static final long serialVersionUID = -4068923271761960454L;
	Logger logger = Logger.getLogger(LocaleBean.class.getName());

	private static final Locale defaultLocale = Locale.ENGLISH;

	private Locale locale = defaultLocale;

	public Locale getLocale()
	{
    return locale;
	}

	public String getLanguage()
	{
    return locale.getLanguage();
	}

	public void setLanguage(String language) 
	{
    locale = new Locale(language);
		FacesContext context = FacesContext.getCurrentInstance();
		context.getViewRoot().setLocale(locale);
	}
}
